package org.sucri.floxs.ext.form;

import org.sucri.floxs.utils.Json_Util;
import org.sucri.floxs.Tools;

/**
 * Created by IntelliJ IDEA.
 * User: Wen Yu
 * Date: Aug 19, 2007
 * Time: 4:53:59 PM
 * To change this template use File | Settings | File Templates.
 */
public class DateField extends FormField
{
  private static final String ALLOW_BLANK = "allowBlank";
  private static final String FORMAT      = "format";

  public DateField(String label, String name, int w)
  {
    super(label, name, w);
    toAllowBlank(false);
    setFormat("m-d-Y");
  }
  public DateField(String label, String name, int w, boolean blank, String format)
  {
    super(label, name, w);
    toAllowBlank(blank);
    setFormat(format);
  }
  public void toAllowBlank(Boolean s) { mConfig.put(ALLOW_BLANK, s); }
  public void setFormat(String s) { if (Tools.good(s)) mConfig.put(FORMAT, s); }
  @Override
  /**
   var employee_hire_date = new Ext.form.DateField({
       fieldLabel: 'Hire Date',
       name: 'hire_date',
       width:90,
       allowBlank:false,
   format:'m-d-Y'
   }); 
   */
  public String construct()
  {
    return Json_Util.newJs("Ext.form.DateField", Json_Util.toJSONString(mConfig));
  }
}
